package main

import "fmt"

type add_func func(int, int) int

func add(a, b int) int {
	return a + b
}

func operator(op add_func, a int, b int) int {
	return op(a, b)
}

func test2() {
	c := add
	fmt.Println(c)
	sum := operator(c, 100, 200)
	fmt.Println(sum)
}

func test() {
	c := add
	fmt.Println(c)

	sum := c(1, 4)
	fmt.Println(sum)
	/*if (c == add) {
		fmt.Println("c equal add")
	}*/
}
func main() {
	//test3()
	test5()
}

func sub(a, b int) int {
	return a - b
}

func test3() {
	c := sub
	fmt.Println(c)
	sum := operator(c, 100, 200)
	fmt.Println(sum)
}

func test4(arg ...int) {

	if len(arg) > 0 {
		fmt.Println(arg[0], arg, len(arg))
	} else {
		fmt.Println("没有参数")
	}
}

func test5() {
	i := 0
	defer fmt.Println("1", i)
	i = 10
	fmt.Println(i)
}
